var Config = require('../config');

var mongoose = Config.get('mongoose');

var ObjectId = mongoose.Schema.Types.ObjectId;

var Schema = mongoose.Schema;

var fansSchema = mongoose.Schema({
	unique_id : Number,
	openid: String,
	subscribe: Number,
	nickname: String,
	sex: Number,
	city: String,
	province: String,
	country: String,
	headimgurl: String,
	subscribe_time: Number,
	unionid: String,
	remark: String,
	groupid: Number,
	created_at: Number
});

var messageSchema = mongoose.Schema({
	unique_id : Number,
	fans: { type: Schema.Types.ObjectId, ref: 'we_fans' },
	message: String,
	created_at: Number
});

var fansTokenSchema = mongoose.Schema({
	openid: String,
	access_token: String,
	expires_in: Number,
	refresh_token: String,
	scope: String,
	created_at: Number
});


exports.Message = mongoose.model('we_messages', messageSchema);

exports.Fans = mongoose.model('we_fans', fansSchema);

exports.FansToken = mongoose.model('we_fans_token', fansTokenSchema);
